package oj;

public class LC1004 {
    public int longestOnes(int[] nums, int k) {
        int n=nums.length;
        int i=0,j=0;
        int count=0;
        int len=Integer.MIN_VALUE;
        while(j<n){
            if(nums[j]==0){
                count++;
            }
            while(count>k){
                if(nums[i]==0){
                    count--;
                }
                i++;
            }
            len=Math.max(len,j-i+1);
            j++;
        }
        return len;
    }
}
